module TrashModel
  extend ActiveSupport::Concern

  included do
    default_scope        -> { where(deleted_at: nil) }
    scope :deleted,      -> { with_deleted.where.not(deleted_at: nil) }
    scope :with_deleted, -> { unscope where: :deleted_at }
  end

  def move_trash
    update_attribute :deleted_at, DateTime.now
  end

  def restore
    update_attribute :deleted_at, nil
  end
end